package com.doublethread.easymart.common.result;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 统一响应状态码枚举
 */
@Getter
@AllArgsConstructor
public enum ResultCode {

    // 成功状态码
    SUCCESS(200, "操作成功"),

    // 客户端错误状态码
    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未授权访问"),
    FORBIDDEN(403, "禁止访问"),
    NOT_FOUND(404, "资源不存在"),

    // 服务器错误状态码
    INTERNAL_SERVER_ERROR(500, "服务器内部错误"),

    // 用户模块
    USER_NOT_FOUND(1001, "用户不存在"),
    USER_DISABLED(1002, "用户已被禁用"),
    INVALID_USERNAME_OR_PASSWORD(1003, "用户名或密码错误"),
    TOKEN_EXPIRED(1004, "登录已过期"),
    TOKEN_INVALID(1005, "登录凭证无效"),
    USERNAME_EXISTS(1006, "用户名已存在"),
    EMAIL_EXISTS(1007, "邮箱已被注册"),
    PHONE_EXISTS(1008, "手机号已被注册"),
    USER_DELETED(1009, "用户已被删除"),

    // 商品模块
    PRODUCT_NOT_FOUND(1101, "商品不存在"),
    PRODUCT_OUT_OF_STOCK(1102, "商品库存不足"),
    PRODUCT_DISABLED(1103, "商品已下架"),
    CATEGORY_NOT_FOUND(1104, "商品分类不存在"),
    CATEGORY_DISABLED(1105, "商品分类已禁用"),
    PRODUCT_NAME_EXISTS(1106, "商品名称已存在"),
    CATEGORY_HAS_CHILDREN(1107, "分类下存在子分类，无法删除"),
    CATEGORY_HAS_PRODUCTS(1108, "分类下存在商品，无法删除"),
    CATEGORY_NAME_EXISTS(1109, "分类名称已存在"),

    // 订单模块
    ORDER_NOT_FOUND(1201, "订单不存在"),
    ORDER_STATUS_ERROR(1202, "订单状态错误"),
    CART_EMPTY(1203, "购物车为空"),
    CART_ITEM_NOT_FOUND(1204, "购物车商品不存在"),
    ORDER_CANNOT_CANCEL(1205, "订单无法取消"),
    ORDER_ALREADY_PAID(1206, "订单已支付"),
    ORDER_EXPIRED(1207, "订单已过期"),
    CART_ITEM_EXISTS(1208, "商品已在购物车中"),

    // 地址模块
    ADDRESS_NOT_FOUND(1301, "收货地址不存在"),
    ADDRESS_LIMIT_EXCEEDED(1302, "收货地址数量超出限制"),
    DEFAULT_ADDRESS_EXISTS(1303, "默认地址已存在"),

    // 评论模块
    COMMENT_NOT_FOUND(1401, "评论不存在"),
    COMMENT_NOT_ALLOWED(1402, "无权限评论"),
    COMMENT_ALREADY_EXISTS(1403, "您已经对该商品进行过评价"),
    COMMENT_PRODUCT_NOT_FOUND(1404, "商品不存在，无法评论"),

    // 文件上传
    FILE_UPLOAD_FAILED(1501, "文件上传失败"),
    FILE_TYPE_NOT_ALLOWED(1502, "文件类型不支持"),
    FILE_SIZE_EXCEEDED(1503, "文件大小超出限制"),

    // 权限模块
    ACCESS_DENIED(1601, "权限不足"),

    // 参数验证
    VALIDATION_FAILED(1701, "参数验证失败");

    /**
     * 状态码
     */
    private final Integer code;

    /**
     * 状态消息
     */
    private final String message;
}
